//----------------------------------Include-------------------------------------
#include "mcu.h"
//------------------------------------------------------------------------------

//------------------------------------Type--------------------------------------
typedef struct{
  uint32_t  cpuclk;
  uint32_t  lfclk;    //32768
  uint32_t  mclk;
  uint32_t  mfclk;    //4MHz
  uint32_t  mfpclk;   //4MHz
  uint32_t  sysosc;
  uint32_t  ulpclk;
}t_clk;
//------------------------------------------------------------------------------

//-----------------------------------Macro--------------------------------------
//内部时钟
#define LFOSC                  (32768)
#define SYSOSC               (4000000)    //4/32 or 16/24MHz
//外部时钟
#define LFXT                   (32768)
#define HFXT                (40000000)    //4~48MHz
//------------------------------------------------------------------------------

//--------------------------------Static Var------------------------------------
static t_clk                 nt_clk;
//------------------------------------------------------------------------------

//--------------------------------Public Func-----------------------------------
void mcu_sys_clock(void)
{
  SYSCFG_DL_init();
  
  delay_cycles(100);
  
  //take from SysConfig clock tree summary
  nt_clk.cpuclk = 80000000;
  nt_clk.lfclk  =    32768;     //低频时钟
  nt_clk.mclk   = 80000000;     //主时钟
  nt_clk.mfclk  =  4000000;     //中频时钟
  nt_clk.mfpclk =  4000000;     //中频精密时钟
  nt_clk.sysosc = 32000000;
  nt_clk.ulpclk = 40000000;     //低功耗时钟
}

uint32_t  mcu_get_mclk(void)  { return nt_clk.mclk;  }
uint32_t  mcu_get_mfclk(void) { return nt_clk.mfclk; }
//------------------------------------------------------------------------------

//------------------------------------EOF---------------------------------------


